import json

from bottle import route,Bottle, request, response ,template ,static_file
from core.wgs84_to_gcj02 import single_check_bag_files_and_extract_data

mapScatterApp = Bottle()

@mapScatterApp.route('/')
def index(filepath="templates/index"):
    # 创建一个列表
    # data = {
    #         "vin123456":[120.7937100727794,31.334872689399628],
    #         "vin456789":[120.789582,31.310440]
    # }

     # 创建一个字典
    # list = [120.7937100727794,31.334872689399628]
    # list = "120.7937100727794,31.334872689399628"
    # list = "120.234684,31.443135"
    file_path = "/common/vis_demo/output/01LNNA28835C92C4F0D8F663CC0ABF9F_1733282068867_140006"
    result_json = single_check_bag_files_and_extract_data(file_path)
    list = f'{result_json["01LNNA28835C92C4F0D8F663CC0ABF9F_1733282068867_190061_all.bag"]["gcj_longitude"]},{result_json["01LNNA28835C92C4F0D8F663CC0ABF9F_1733282068867_190061_all.bag"]["gcj_latitude"]}'
    print(f" BOSCH 返回经纬度：{list}")
    return template(filepath,list=list)

# 定义静态文件的路由
@mapScatterApp.route('/static/<filename:path>')
def server_static(filename):
    return static_file(filename, root='./static')